//
//  RankViewController.m
//  UESTCPioneer
//
//  Created by sss on 14-8-23.
//  Copyright (c) 2014年 Sway. All rights reserved.
//

#import "RankViewController.h"
#import "CellForLeaderboard.h"
#import "CellForStatistics.h"
#import "LeaderboardEntity.h"
#import "StatisticsEntity.h"
#import "MBProgressHUD.h"

#pragma mark - 颜色
#define kNavigationBarColor [UIColor colorWithRed:192.0/255.0 green:57.0/255.0 blue:43.0/255.0 alpha:1]
#define KSPEColor [UIColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:1]
#define KBtnTextColor [UIColor colorWithRed:119.0/255.0 green:119.0/255.0 blue:119.0/255.0 alpha:1]

#define kOffsetY 47
#define kOffsetH 165
#define kWidth 320

#define kToRight @"toRight"
#define kToLeft @"toLeft"
@interface RankViewController ()<UITableViewDataSource,UITableViewDelegate>{
    UIButton *institute;
    UIButton *branch;
    UIButton *detail;
    UIView *slideBar;
    
    UITableView *table;
    NSMutableArray *tabDataArray;
    NSArray *instituteArray;
    NSArray *branchArray;
    NSArray *statisticsArray;
    
    NSArray *theBranchOfSelectInstitute;
    
    UIView *view1;
    UIView *view2;
    //displayType = YES  ------>View1显示View2隐藏
    //displayType = NO   ------>View2显示View1隐藏
    BOOL displayType;
    //设置滑动方向
    NSString *slideDir;
    //statistics的表格不一样
    BOOL isStatistics;
    //学院与支部区分标志
    BOOL isCollege;
    //数据统计的返回标识
    UIActivityIndicatorView *_activityView;
    
    //------------ Sakura-2014-10-09 begin 修改-------------
    NSArray *cellDataArr;
    //------------ Sakura end ---------------
}
@property (nonatomic,strong) UIView * indicatorView;
@end

@implementation RankViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    displayType = YES;
    isStatistics = NO;
    isCollege = YES;
    //    canBackNum = 2;
    slideDir = kToLeft;
    tabDataArray  = [[NSMutableArray alloc] init];
    [self getRankList];
    [self getBranchData];
    [self getStatisticsData];
    self.height = self.view.frame.size.height;
    
    UIView *headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kWidth, 47)];
    headView.backgroundColor = [UIColor whiteColor];
    
    UIView *barLine = [[UIView alloc] initWithFrame:CGRectMake(0, 47, kWidth,1)];
    barLine.backgroundColor = KSPEColor;
    [headView addSubview:barLine];
    
    institute = [self addBtn:CGRectMake(0, 0, kWidth/3, 47) title:@"学院排行" tag:1 normalColor:kNavigationBarColor];
    [headView addSubview:institute];
    
    branch = [self addBtn:CGRectMake(kWidth/3, 0, kWidth/3, 47) title:@"支部排行" tag:2 normalColor:KBtnTextColor];
    [headView addSubview:branch];
    
    detail = [self addBtn:CGRectMake(2*kWidth/3, 0, kWidth/3, 47) title:@"个人排行" tag:3 normalColor:KBtnTextColor];
    [headView addSubview:detail];
    
    slideBar = [[UIView alloc] initWithFrame:CGRectMake(0, 43, kWidth/3, 4)];
    slideBar.backgroundColor = kNavigationBarColor;
    [headView addSubview:slideBar];
    [self.view addSubview:headView];
    
    view1 = [[UIView alloc] initWithFrame:CGRectMake(0, kOffsetY, kWidth, self.view.frame.size.height - kOffsetH)];
    NSArray *view1Titles = @[@"排名",@"学院",@"活跃指数",@"排名变化"];
    [self setTableData:tabDataArray viewTitle:view1Titles hasBtn:NO hasAccory:NO];
    
    view2 = [[UIView alloc] initWithFrame:CGRectMake(kWidth, kOffsetY, kWidth, self.view.frame.size.height - kOffsetH)];
    
    [self.view addSubview:view1];
    [self.view addSubview:view2];
    
    
    CGFloat x = (self.view.frame.size.width - 37)/2;
    CGFloat y = ([UIApplication sharedApplication].keyWindow.bounds.size.height - 37)/2;
    self.indicatorView = [[UIView alloc] initWithFrame:CGRectMake(x, y - 50, 38, 38)];
    [[UIApplication sharedApplication].keyWindow addSubview:self.indicatorView];
    _activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:
                     UIActivityIndicatorViewStyleWhiteLarge] ;
    [self.indicatorView addSubview:_activityView];
    _activityView.color = [UIColor grayColor];
    [_activityView startAnimating];
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.leveyTabBarController.navigationItem setTitle:@"活跃排行"];
    [self.navigationItem setTitle:@""];
    UIButton *leftMenu = [UIButton buttonWithType:UIButtonTypeCustom];
    [leftMenu setImage:[UIImage imageNamed:@"menu.png"] forState:UIControlStateNormal];
    [leftMenu setImageEdgeInsets:UIEdgeInsetsMake(12, 12, 12, 42)];
    [leftMenu addTarget:self action:@selector(leftMenuClick) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *button  = [helper BarButtonItemWithUIButton:leftMenu ButtonOrigin:CGPointMake(0, 0)];
    [self.leveyTabBarController.navigationItem setLeftBarButtonItem:button];
    
    [self.leveyTabBarController.navigationItem setRightBarButtonItem:nil];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [_activityView stopAnimating];
}

#pragma mark -
#pragma mark 设置title
//1.添加按钮
-(UIButton *)addBtn:(CGRect)rect title:(NSString*)title tag:(NSInteger)tag normalColor:(UIColor*)color{
    UIButton *btn = [[UIButton alloc] initWithFrame:rect];
    [btn setTitle:title forState:UIControlStateNormal];
    btn.tag = tag;
    [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    [btn setTitleColor:kNavigationBarColor forState:UIControlStateHighlighted];
    [btn setTitleColor:color forState:UIControlStateNormal];
    return btn;
}
//2.按钮点击
-(void)btnClick:(UIButton*)btn{
    
    isStatistics = NO;
    [institute setTitleColor:KBtnTextColor forState:UIControlStateNormal];
    [branch setTitleColor:KBtnTextColor forState:UIControlStateNormal];
    [detail setTitleColor:KBtnTextColor forState:UIControlStateNormal];
    [btn setTitleColor:kNavigationBarColor forState:UIControlStateNormal];
    [self Animation:(btn.tag-1)];
    NSArray *Titles;
    NSArray *data;
    BOOL hasBtn = NO;
    BOOL hasAccecor = NO;
    
    [_activityView stopAnimating];
    if (btn.tag == 1) {
        isCollege = YES;
        Titles = @[@"排名",@"学院",@"活跃指数",@"排名变化"];
        data = [NSArray arrayWithArray:instituteArray];
        slideDir = kToRight;
        [self slideViewWithDisplayType:displayType to:slideDir];
        slideDir = kToLeft;
    }
    if (btn.tag == 2) {
        isCollege = NO;
        Titles = @[@"排名",@"支部",@"活跃指数",@"排名变化"];
        data = [NSArray arrayWithArray:branchArray];
        [self slideViewWithDisplayType:displayType to:slideDir];
    }
    if (btn.tag == 3) {
        isStatistics = YES;
        hasAccecor = YES;
            Titles = @[@"排名",@"个人",@"个人积分",@"排名变化"];
        data = [NSArray arrayWithArray:statisticsArray];
        slideDir = kToLeft;
        [self slideViewWithDisplayType:displayType to:slideDir];
        slideDir = kToRight;
    }
    [self setTableData:data viewTitle:Titles hasBtn:hasBtn hasAccory:hasAccecor];
    
}
//根据当前显示的页面方式来决定滑动方式-----View1显示View2隐藏   或者   View2显示View1隐藏 ???
-(void)slideViewWithDisplayType:(BOOL)disType to:(NSString*)toDirection{
    if (disType) {
        [self slideView:view1 ToDirection:toDirection isHide:NO];
        [self slideView:view2 ToDirection:toDirection isHide:YES];
    }else{
        [self slideView:view2 ToDirection:toDirection isHide:NO];
        [self slideView:view1 ToDirection:toDirection isHide:YES];
    }
    displayType = !displayType;
}

//3.滑条动画
-(void)Animation:(int)selelctTag{
    CGRect newFram = slideBar.frame;
    newFram = CGRectMake(selelctTag * kWidth/3, 43, kWidth/3, 4);
    [UIView beginAnimations:@"slide" context:nil];
    [UIView setAnimationDuration:0.40];
    [slideBar setFrame:newFram];
    [UIView commitAnimations];
}


#pragma mark -
#pragma mark 设置View的content
//1.setView
-(void)setViewContentWithTitleName:(NSArray*)titleArr hasBackBtn:(BOOL)hasBackBtn AccecoryOffset:(BOOL)hasAccecory forView:(UIView*)view{
    
    for (UIView *views in view.subviews) {
        [views removeFromSuperview];
    }
    CGFloat contentOffsetY = 0;
    CGFloat accecoryOffset = 10;

    UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(0, contentOffsetY, kWidth, 30)];
    [self setTitleForView:titleView titleName:titleArr offset:accecoryOffset titleColor:[UIColor blackColor]];
    [view addSubview:titleView];
}
//2.setTitleView
-(void)setTitleForView:(UIView*)view titleName:(NSArray*)titleArr offset:(CGFloat)offset titleColor:(UIColor*)color{
    
    UIView *barLine = [[UIView alloc] initWithFrame:CGRectMake(0, 30, kWidth, 1)];
    barLine.backgroundColor = KSPEColor;
    [view addSubview:barLine];
    
    [self addLabel:CGRectMake(0, 2, 40, 25) title:titleArr[0] forView:view alignType:NSTextAlignmentCenter titleColor:color];
    [self addLabel:CGRectMake(30, 2, 170, 25) title:titleArr[1]forView:view alignType:NSTextAlignmentCenter titleColor:color];
    [self addLabel:CGRectMake(200, 2,50 + offset, 25) title:titleArr[2]forView:view alignType:NSTextAlignmentLeft titleColor:color];
    [self addLabel:CGRectMake(250 + offset, 2, 50 + offset, 25) title:titleArr[3]forView:view alignType:NSTextAlignmentLeft titleColor:color];
}
-(void)setTitleForStudentView:(UIView*)view titleName:(NSArray*)titleArr offset:(CGFloat)offset titleColor:(UIColor*)color{
    
    UIView *barLine = [[UIView alloc] initWithFrame:CGRectMake(0, 30, kWidth, 1)];
    barLine.backgroundColor = KSPEColor;
    [view addSubview:barLine];
    
    [self addLabel:CGRectMake(15, 2, 40, 25) title:titleArr[0] forView:view alignType:NSTextAlignmentCenter titleColor:color];
    [self addLabel:CGRectMake(55, 2, 200, 25) title:titleArr[1]forView:view alignType:NSTextAlignmentCenter titleColor:color];
    [self addLabel:CGRectMake(255, 2,50 + offset, 25) title:titleArr[2]forView:view alignType:NSTextAlignmentLeft titleColor:color];
}

-(void)addLabel:(CGRect)rect title:(NSString*)title forView:(UIView*)view alignType:(NSTextAlignment)alignType titleColor:(UIColor*)color{
    UILabel *label = [[UILabel alloc] initWithFrame:rect];
    label.text = title;
    label.textAlignment = alignType;
    label.textColor = color;
    label.font = [UIFont systemFontOfSize:14.0];
    [view addSubview:label];
    
}


#pragma mark -
#pragma mark 切换
-(void)slideView:(UIView*)view ToDirection:(NSString*)toDirection isHide:(BOOL)isHide{
    
    CGRect viewFram = view.frame;
    if (isHide) {
        [self initHideViewWithSlideDirection:toDirection forView:view];
        viewFram = CGRectMake(0, kOffsetY, kWidth, view.frame.size.height);
    }else{
        if ([toDirection isEqualToString:kToRight]) {
            viewFram = CGRectMake(kWidth, kOffsetY, kWidth, view.frame.size.height);
        }
        if ([toDirection isEqualToString:kToLeft]) {
            viewFram = CGRectMake(-kWidth, kOffsetY, kWidth, view.frame.size.height);
        }
    }
    [UIView beginAnimations:@"viewSlide" context:nil];
    [UIView setAnimationDuration:0.40];
    [view setFrame:viewFram];
    [UIView commitAnimations];
    
}
-(void)initHideViewWithSlideDirection:(NSString*)direction forView:(UIView*)view{
    NSLog(@"====================================================5");
    CGRect hideFram = view.frame;
    if ([direction isEqualToString:kToRight]) {
        hideFram = CGRectMake(-320, kOffsetY, kWidth, view.frame.size.height);
    }else if([direction isEqualToString:kToLeft]){
        hideFram = CGRectMake(320, kOffsetY, kWidth, view.frame.size.height);
    }
    view.frame = hideFram;
    
}

//改变table中的数据
-(void)setTableData:(NSArray*)dataArr viewTitle:(NSArray*)titleArr hasBtn:(BOOL)hasBtn hasAccory:(BOOL)hasAccecory{
    //    [tabDataArray removeAllObjects];
    [table removeFromSuperview];
    //点击按钮时还没有改变display的值，因此display = YES 表示当前显示的时View1 即将显示的应该是View2！！！！！所以在点击按钮后，调用此函数之前应该先改变display的值
    CGFloat offsetY = 0;
    NSLog(@"displayType = %i",displayType);
    if (displayType) {
        [self setViewContentWithTitleName:titleArr hasBackBtn:hasBtn AccecoryOffset:hasAccecory forView:view1];
        [self addTable:view1 withData:dataArr offsetY:offsetY];
        
    }else{
        [self setViewContentWithTitleName:titleArr hasBackBtn:hasBtn AccecoryOffset:hasAccecory forView:view2];
        
        [self addTable:view2 withData:dataArr offsetY:offsetY];
        
    }
    
}

#pragma mark -
#pragma mark 初始化表格
-(void)addTable:(UIView*)targetView withData:(NSArray*)dataSource offsetY:(CGFloat)offsetY{
    
    if (!table) {
        table = [[UITableView alloc] initWithFrame:CGRectMake(0, 31 + offsetY, self.view.frame.size.width, self.height - 195 - offsetY) style:UITableViewStylePlain];
        table.delegate = self;
        table.dataSource = self;
        if(IS_IOS7)
            [table setSeparatorInset:UIEdgeInsetsZero];
    }
    CGRect fram = table.frame;
    fram = CGRectMake(0, 31 + offsetY, self.view.frame.size.width, self.height - 195 -offsetY);
    table.frame = fram;
    
    [table removeFromSuperview];
    [tabDataArray removeAllObjects];
    
    [tabDataArray addObjectsFromArray:dataSource];
    
    [table registerClass:[CellForLeaderboard class] forCellReuseIdentifier:@"statistics"];
    [table registerClass:[CellForLeaderboard class] forCellReuseIdentifier:@"leaderboard"];
    [self clearExraTab];
    [targetView addSubview:table];
    [table reloadData];
    
}

-(void)clearExraTab{
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = [UIColor clearColor];
    [table setTableFooterView:view];
}

#pragma mark -
#pragma mark table delegate cell

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    CellForLeaderboard *cell = [tableView dequeueReusableCellWithIdentifier:@"leaderboard" forIndexPath:indexPath];
    if (cell == nil) {
        cell = [[CellForLeaderboard alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"leaderboard"];
    }
    cell.userInteractionEnabled = NO;
    cell.notelabel.hidden = YES;
    if (tabDataArray.count<1) {
        return cell;
    }
    
    [self setInstituteOrBranchCell:cell indexPath:indexPath];
    return cell;
}
//set the cell in one row data
-(void)setCellData:(int)atRow{
    if (isStatistics) {
        NSLog(@"个人");
        StatisticsEntity *entity = tabDataArray[atRow];

        NSLog(@"entity = %@",entity);
        NSString *rank = entity.nowrank;
        
        NSLog(@"rank = %@",rank);
        NSString *rankChange = [NSString stringWithFormat:@"%@",entity.rankchange];
        cellDataArr = @[rank,entity.institute,entity.vitality,rankChange];

    }else{
        LeaderboardEntity *selfEntity = tabDataArray[atRow];
        cellDataArr = @[selfEntity.nowrank,selfEntity.branch,selfEntity.index,selfEntity.rankchange];
    }
}

//设置学院和支部排行的cell------CellForLeaderboard
-(void)setInstituteOrBranchCell:(CellForLeaderboard *)cell indexPath:(NSIndexPath *)indexPath{

    cell.changeLabel.textColor = [UIColor grayColor];
    cell.rank.text = [NSString stringWithFormat:@"%i",indexPath.row+1];
    if (indexPath.row == tabDataArray.count - 1) {
        NSLog(@"倒数第二行");
        cell.headImg.image = [UIImage imageNamed:@""];
        cell.rank.text = @"";
        cell.instOrbranch.text = @"";
        cell.actIndex.text = @"";
        cell.changeLabel.text = @"";
        cell.changeImg.image = [UIImage imageNamed:@""];
        cell.notelabel.frame = CGRectMake(0, 0, cell.frame.size.width,cell.frame.size.height);
        if (isStatistics) {
            cell.notelabel.text = @"我的排名";
        }else{
            if (isCollege) {
                cell.notelabel.text = @"本学院排名";
            }else{
                cell.notelabel.text = @"本支部排名";
            }
        }
        
        cell.notelabel.hidden = NO;
        return;
    }else if(indexPath.row == tabDataArray.count){
        NSLog(@"最后一行");
        [self setCellData:10];
        cell.headImg.image = [UIImage imageNamed:@""];
        cell.rank.text = cellDataArr[0];
        cell.instOrbranch.text = cellDataArr[1];
        cell.actIndex.text = cellDataArr[2];
        UIImage *changeImg = [UIImage imageNamed:@"equal.png"];
        NSString *change = cellDataArr[3];
        
        if ([cellDataArr[3] integerValue] > 0) {
            cell.changeLabel.textColor = [UIColor redColor];
            changeImg = [UIImage imageNamed:@"up.png"];
        }else if ([cellDataArr[3] integerValue]<0){
            cell.changeLabel.textColor = [UIColor greenColor];
            changeImg = [UIImage imageNamed:@"down.png"];
            change = [cellDataArr[3] substringFromIndex:1];
        }
        cell.changeImg.image = changeImg;
        cell.changeLabel.text =change;
        return;
    }

    [self setCellData:indexPath.row];

    cell.instOrbranch.text = cellDataArr[1];

    cell.actIndex.text = cellDataArr[2];

    UIImage *changeImg = [UIImage imageNamed:@"equal.png"];

    NSString *change = cellDataArr[3];
 
    if ([cellDataArr[3] integerValue] > 0) {
  
        cell.changeLabel.textColor = [UIColor redColor];
       
        changeImg = [UIImage imageNamed:@"up.png"];
      
    }else if ([cellDataArr[3] integerValue]<0){
     
        cell.changeLabel.textColor = [UIColor greenColor];
       
        changeImg = [UIImage imageNamed:@"down.png"];
     
        change = [cellDataArr[3] substringFromIndex:1];
   
    }

    cell.changeImg.image = changeImg;

    cell.changeLabel.text =change;

    UIImage *img;
    if (indexPath.row == 0) {
  
        cell.rank.text = @"";
        img = [UIImage imageNamed:@"one1.png"];
    }else if(indexPath.row == 1){
     
        cell.rank.text = @"";
        img = [UIImage imageNamed:@"two2.png"];
    }else if(indexPath.row == 2){
     
        cell.rank.text = @"";
        img = [UIImage imageNamed:@"three3.png"];
    }
 
    cell.headImg.image = img;

}
//设置数据统计的cell------CellForStatistics
-(void)setStatisticsCell:(CellForStatistics *)cell indexPath:(NSIndexPath *)indexPath{
    StatisticsEntity *entity = tabDataArray[indexPath.row];
    cell.rankLable.text = [NSString stringWithFormat:@"%i",indexPath.row + 1];
    cell.nameLabel.text = entity.institute;
    cell.actIndexLable.text = entity.vitality;
        [cell setElementFrame];
        cell.attentionLable.hidden = YES;
        cell.accessoryType = UITableViewCellAccessoryNone;

}

#pragma mark -
#pragma mark table setting
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
//    if (isStatistics) {
//        return tabDataArray.count;
//    }
//    if (tabDataArray.count>0) {
//        LeaderboardEntity *selfEntity = tabDataArray[tabDataArray.count-1];
//        if([selfEntity.nowrank isEqualToString:@"0"]) {
//            NSLog(@"--------------------00000000test for s------------------");
//            
//            return tabDataArray.count - 1;
//            
//        }
//    }
    
    return tabDataArray.count + 1;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (!isStatistics) {
        if (indexPath.row == tabDataArray.count -1) {
            return 24.0f;
        }
    }
    return 37.0f;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 0.1;
}

#pragma mark -
#pragma mark 网络访问获取排名数据

-(void)getRankList{
    //    MBProgressHUD * hud  = [MBProgressHUD showHUDAddedTo:self.view.window animated:YES];
    //    hud.labelText = @"数据获取中...";
    //    hud.dimBackground = YES;
    NSDictionary *reqDic = @{@"type": @"getRanklist",
                             @"userId": [constant getUserId],
                             @"typepid":@"college"};
    [NetworkCenter RKRequestWithData:reqDic EntityName:@"LeaderboardEntity" Mapping:[Mapping LeaderboardEntityMapping] SuccessBlock:^(NSArray *resultArray) {
        
        instituteArray = [NSArray arrayWithArray:resultArray];
        
        [tabDataArray addObjectsFromArray:instituteArray];
        
        [table reloadData];
        [_activityView stopAnimating];
        //        [MBProgressHUD hideAllHUDsForView:self.view.window animated:YES];
    } failure:^(NSError *error) {
        [Alert showAlert:@"数据获取错误"];
        //        [MBProgressHUD hideAllHUDsForView:self.view.window animated:YES];
        [_activityView stopAnimating];
    }];
}

-(void)getBranchData{
    [_activityView startAnimating];
    NSDictionary *reqDicInstitute = @{@"type": @"getRanklist",
                                      @"userId": [constant getUserId],
                                      @"typepid":@"branch"};
    [NetworkCenter RKRequestWithData:reqDicInstitute EntityName:@"LeaderboardEntity" Mapping:[Mapping LeaderboardEntityMapping] SuccessBlock:^(NSArray *resultArray) {
        
        branchArray = [NSArray arrayWithArray:resultArray];
        [_activityView stopAnimating];
    } failure:^(NSError *error) {
        [Alert showAlert:@"数据获取错误"];
        [_activityView stopAnimating];
    }];
}

-(void)getStatisticsData{
    [_activityView startAnimating];
    NSDictionary *reqStatistics = @{@"type": @"getAttentionRanklist",
                                    @"userId":[constant getUserId]};
    [NetworkCenter RKRequestWithData:reqStatistics EntityName:@"StatisticsEntity" Mapping:[Mapping StatisticsEntityMapping] SuccessBlock:^(NSArray *resultArray) {
        statisticsArray = [NSArray arrayWithArray:resultArray];

        [_activityView stopAnimating];
    } failure:^(NSError *error) {
        [Alert showAlert:@"数据获取错误"];
        [_activityView stopAnimating];
    }];
}

#pragma mark -
#pragma mark 侧滑按钮点击

-(void)leftMenuClick{
    [self.leveyTabBarController.revealSideViewController pushOldViewControllerOnDirection:PPRevealSideDirectionLeft animated:YES];
}
@end
